/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package javamail.web.util;

/**
 *
 * @author sriram
 */
public enum eParseOption {
    NIL(0, "NIL"), HOST(1, "Host:"), USER_AGENT(2,"User-Agent:"), 
    ACCEPT(3, "Accept:"), ACCEPT_LANG(4, "Accept-Langauge:"), 
    ACCEPT_ENC(5, "Accept-Encoding:"), ACCEPT_CHAR(6, "Accept-Charset:"), 
    KEEP_ALIVE(7, "Keep-Alive:"), CONTENT_TYPE(9, "Content-Type:"),
    CONN(8, "Connection:"), CACHE(9, "Cache-Control"),
    EOL(10, "\r\n"), MAXOPT(11, "NIL");

    private final int index;
    private final String str;
    
    eParseOption(int id, String string) {
        this.index = id;
        this.str = string;
    }
    
    public int toInt() {
        return index;
    }
 
    public String toString() {
        return str;
    }
 
    public static eParseOption fromString(final String str) {
        for (eParseOption opt : eParseOption.values()) {
            if (opt.toString().equalsIgnoreCase(str)) {
                return opt;
            }
        }
        return NIL;
    }
 
    public static eParseOption fromInt(final int index) {
        for (eParseOption opt : eParseOption.values()) {
            if (opt.index == index) {
                return opt;
            }
        }
        return NIL;
    }
}
